$(document).ready( function() {
    $('#submit').click( function() {
        get_victim_by_id()
        })
})

function get_victim_by_id() {
    try {
        target_account_id = $('#target_account_id').val();
        minimum_followers_count = $('#minimum_followers_count').val();
        maximum_followers_count = $('#maximum_followers_count').val();
        maximum_follow_count = $('#maximum_followers_count').val();
        minimum_post_count = $('#minimum_post_count').val();
        minimum_register_days = $('#minimum_register_days').val();
        maximum_register_days = $('#maximum_followers_count').val();
        user_location = $('#user_location').val();
        
        var proceed = confirm('will get victim for ' + target_account_id + 'proceed?');
        
        if (proceed) {
            $.ajax({
                url: '/cgi/get_victim.py',
                type: 'GET',
                data: {
                       target_account_id: target_account_id,
                       minimum_followers_count: minimum_followers_count,
                       maximum_followers_count: maximum_followers_count,
                       maximum_follow_count: maximum_follow_count,
                       minimum_post_count: minimum_post_count,
                       minimum_register_days: minimum_register_days,
                       maximum_register_days: maximum_register_days,
                       user_location: encodeURI(user_location)
                },
                success: function(data) {
                    alert('ajax success: ' + data);
                    console.log(data);
                },
                error: function(data) {
                    alert('ajax failed: ' + data);
                    console.log(data)
                }
            })
        }
    }
    catch (err) {
        alert('unexpected error: ' + err);
    }
}
